<template>
  <div class="app-container">
    <el-form inline>
      <el-form-item label='  '> 
      </el-form-item>
    </el-form> 
    <el-table :data="tableData" border stripe> 
      <el-table-column type="index" align="center" width="50"></el-table-column>
      <el-table-column label='实例名称' prop="instanceName" align="center"></el-table-column> 
      <el-table-column label='standalone' prop="standalone" align="center"></el-table-column>
      <el-table-column label='优先级' prop="priority" align="center"></el-table-column>
      <el-table-column label='责任人' prop="assignee" align="center"></el-table-column> 
      <el-table-column label='流程状态' prop="status" align="center"> </el-table-column> 
      <el-table-column label='开始时间' prop="createdDate" align="center"></el-table-column>
      <el-table-column label='基础操作' align="center">
        <template slot-scope="scope"> 
          <el-button type="text" @click="readyHandle">办理</el-button>
          <el-button type="text" @click="completeTask(scope.row)">直接通过</el-button>
        </template>
      </el-table-column>
    </el-table>
        
  </div>
</template>

<script>  
export default { 
  data() {
    return {  
      total:0,
      tableData:[],
      currentPage:1,
      showUpdate:false,
      tmpTeam:{
        id:-1,
        name:null,
        provinceCode:null,
        provinceName:null,
        leader:null,
        serial:0
      }
    }
  },
  created() { 
    this.getList()
  },
  methods: {
    getList(){
      this.$api.getTasks().then(res=>{
        if (res.status == 0) {
            this.tableData = res.data 
        }else{
          this.$message.error("获取任务失败！")
        }
        
      })
    }, 
    startProcessInstance(processDefined){
        let key = processDefined.key
        this.$prompt("请输入流程示例名称", "准备部署", {
        confirmButtonText: "确定",
        cancelButtonText: "取消", 
      })
        .then(({ value }) => {
            this.$message({
                type: "success",
                message: "正在部署中...",
            });
            let instanceName = value
            this.$api.startProcessInstance(key,instanceName).then(res=>{
                console.log(res);
            })


        })
        .catch(() => {
         
        });
    },
    readyHandle(){
       this.$message.warning("功能还没开发好")
    },
    completeTask(task){
        this.$api.completeTask(task.id).then(res=>{
          if (res.status == 0) {
            this.$message.success("任务完成！")
            this.getList()
          }else{
            this.$message.error(res.msg)
          }
        })
    }
  }
}
</script>
